/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logicwin.RobotTravel;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.VideoView;
import com.logicwin.RobotTravel.Screens.FullScreenVideo;
import com.logicwin.RobotTravel.Screens.ScreenVideo;
import com.logicwin.RobotTravel.utils.ConfigUtils;

/**
 *
 * @author chapeng
 */
public class IntroDialogTabVideo extends Activity
{

    private boolean hasVideo = false;
    /*private VideoView videoView;
    private View image;
    private LinearLayout layout;*/

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.intro_video);
        /*layout = (LinearLayout) this.findViewById(R.id.videolayout);
        image = (View)this.findViewById(R.id.videoback);
        videoView = (VideoView) findViewById(R.id.VideoView01);*/

        String sceen = this.getIntent().getExtras().getString("sceen");
        hasVideo = ConfigUtils.hasVideo(sceen);
        Resources res = this.getResources();
        ImageView view = (ImageView)this.findViewById(R.id.intro_video_view);
        view.setImageDrawable(res.getDrawable(ConfigUtils.getDrawable(sceen, 2)));
        
    }

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        switch (event.getAction())
        {
            case MotionEvent.ACTION_DOWN:
                //Log.i("IntroDialogTabVideo", "IntroDialogTabVideo::onTouchEvent is catched.");
            	if (hasVideo) {
	                Intent intent = new Intent(this, FullScreenVideo.class);
	                this.startActivity(intent);
            	}
                /*if (!playing)
                {
                    if (videoView == null)
                    {
                        videoView = (VideoView) getLayoutInflater().inflate(R.layout.video_view, null);
                        //this.layout.removeAllViews();
                        this.layout.addView(videoView);
                        this.layout.removeView(image);
                        //this.setContentView(videoView);
                    }
                    playing = true;
                    videoView.setVideoPath("/sdcard/VID.3gp");
                    videoView.setMediaController(new MediaController(this));
                    videoView.requestFocus();
                    videoView.start();
                } else {
                    playing = false;
                    videoView.pause();
                }*/
                return true;
            case MotionEvent.ACTION_UP:

                return true;

        }
        return super.onTouchEvent(event);
    }
}

